//
//  HomeSleepDescView.m
//  Ginix
//
//  Created by 冯志强 on 2025/3/16.
//

#import "HomeSleepDescView.h"

@interface HomeSleepDescView()
@property (nonatomic,strong) YYLabel * labe1;
@property (nonatomic,strong) YYLabel * labe2;
@property (nonatomic,strong) YYLabel * labe3;
@property (nonatomic,strong) YYLabel * labe4;
@end

@implementation HomeSleepDescView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.location = CenterStyle;
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    self.contentView.frame = CGRectMake(40 *  FMScaleX, (HEIGHT - 400 * FMScaleX) / 2, WIDTH - 80 * FMScaleX, 400 * FMScaleX );
    [self.contentView setCornerRadius: 8 * FMScaleX];
    self.contentView.backgroundColor = UIColor.whiteColor;
    
    [self.contentView addSubview:self.labe1];
    [_labe1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(@0);
        make.top.mas_offset(20 * FMScaleX);
        make.size.mas_offset(CGSizeMake(WIDTH - 80 * FMScaleX - 40 * FMScaleX, 80 * FMScaleX));
    }];
    [self.contentView addSubview:self.labe2];
    [_labe2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(WIDTH - 80 * FMScaleX - 40 * FMScaleX, 80 * FMScaleX));
        make.centerX.equalTo(@0);
        make.top.equalTo(self.labe1.mas_bottom).offset(10 * FMScaleX);
    }];
    [self.contentView addSubview:self.labe3];
    [_labe3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(WIDTH - 80 * FMScaleX - 40 * FMScaleX, 80 * FMScaleX));
        make.centerX.equalTo(@0);
        make.top.equalTo(self.labe2.mas_bottom).offset(10 * FMScaleX);
    }];
    [self.contentView addSubview:self.labe4];
    [_labe4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(WIDTH - 80 * FMScaleX - 40 * FMScaleX, 80 * FMScaleX));
        make.centerX.equalTo(@0);
        make.top.equalTo(self.labe3.mas_bottom).offset(10 * FMScaleX);
    }];
    
}

-(YYLabel *)labe1{
    
    if (!_labe1) {
        _labe1 = [[YYLabel alloc]init];
        NSMutableAttributedString * attstr = [[NSMutableAttributedString alloc]initWithString:@" 绿色(优秀)85-100分\n您的睡眠质量非常棒!继续保持良好的作息习惯。"];
        NSMutableAttributedString * obj = [NSMutableAttributedString yy_attachmentStringWithContent:({
            UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10 * FMScaleX, 10 * FMScaleX)];
            line.backgroundColor = RDRGB(0x27C824);
            [line setCornerRadius:5 * FMScaleX];
            line;
              }) contentMode:UIViewContentModeRight attachmentSize:CGSizeMake(12 * FMScaleX, 10 * FMScaleX) alignToFont:Regular(14) alignment:YYTextVerticalAlignmentCenter];
        [attstr insertAttributedString:obj atIndex:0];
        _labe1.attributedText = attstr;
        _labe1.font = Regular(14);
        _labe1.textColor = RDRGB(0x000000);
        _labe1.numberOfLines = 0;
    }
    return _labe1;
}

-(YYLabel *)labe2{
    
    if (!_labe2) {
        _labe2 = [[YYLabel alloc]init];
        NSMutableAttributedString * attstr = [[NSMutableAttributedString alloc]initWithString:@" 蓝色(良好)70-84 分\n您的睡眠质量不错，但仍有优化空间，建议关注深睡眠和 REM 睡眠时长。"];
        NSMutableAttributedString * obj = [NSMutableAttributedString yy_attachmentStringWithContent:({
            UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10 * FMScaleX, 10 * FMScaleX)];
            line.backgroundColor = RDRGB(0x4595FE);
            [line setCornerRadius:5 * FMScaleX];
            line;
              }) contentMode:UIViewContentModeRight attachmentSize:CGSizeMake(12 * FMScaleX, 10 * FMScaleX) alignToFont:Regular(14) alignment:YYTextVerticalAlignmentCenter];
        [attstr insertAttributedString:obj atIndex:0];
        _labe2.attributedText = attstr;
        _labe2.font = Regular(14);
        _labe2.textColor = RDRGB(0x000000);
        _labe2.numberOfLines = 0;
    }
    return _labe2;
}
-(YYLabel *)labe3{
    
    if (!_labe3) {
        _labe3 = [[YYLabel alloc]init];
        NSMutableAttributedString * attstr = [[NSMutableAttributedString alloc]initWithString:@" 黄色(一般)50-69 分\n您的睡眠质量一般，可能存在睡眠不足或结构不合理的问题，建议调整作息。"];
        NSMutableAttributedString * obj = [NSMutableAttributedString yy_attachmentStringWithContent:({
            UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10 * FMScaleX, 10 * FMScaleX)];
            line.backgroundColor = RDRGB(0xFBD058);
            [line setCornerRadius:5 * FMScaleX];
            line;
              }) contentMode:UIViewContentModeRight attachmentSize:CGSizeMake(12 * FMScaleX, 10 * FMScaleX) alignToFont:Regular(14) alignment:YYTextVerticalAlignmentCenter];
        [attstr insertAttributedString:obj atIndex:0];
        _labe3.attributedText = attstr;
        _labe3.font = Regular(14);
        _labe3.textColor = RDRGB(0x000000);
        _labe3.numberOfLines = 0;
    }
    return _labe3;
}
-(YYLabel *)labe4{
    
    if (!_labe4) {
        _labe4 = [[YYLabel alloc]init];
        NSMutableAttributedString * attstr = [[NSMutableAttributedString alloc]initWithString:@" 红色(不佳)<50 分\n您的睡眠质量较差，可能存在严重睡眠问题，建议咨询专业医生。"];
        NSMutableAttributedString * obj = [NSMutableAttributedString yy_attachmentStringWithContent:({
            UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10 * FMScaleX, 10 * FMScaleX)];
            line.backgroundColor = RDRGB(0xFB5252);
            [line setCornerRadius:5 * FMScaleX];
            line;
              }) contentMode:UIViewContentModeRight attachmentSize:CGSizeMake(12 * FMScaleX, 10 * FMScaleX) alignToFont:Regular(14) alignment:YYTextVerticalAlignmentCenter];
        [attstr insertAttributedString:obj atIndex:0];
        _labe4.attributedText = attstr;
        _labe4.font = Regular(14);
        _labe4.textColor = RDRGB(0x000000);
        _labe4.numberOfLines = 0;
    }
    return _labe4;
}


@end
